home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 21 / AACD 21.iso / AACD / Utilities / Ghostscript / src / math_.h < prev    next >
Encoding:
C/C++ Source or Header  |  2001-01-01  |  2.8 KB  |  87 lines

  1. /* Copyright (C) 1989, 1995, 1998, 1999 Aladdin Enterprises.  All rights reserved.
  2.   
  3.   This file is part of AFPL Ghostscript.
  4.   
  5.   AFPL Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author or
  6.   distributor accepts any responsibility for the consequences of using it, or
  7.   for whether it serves any particular purpose or works at all, unless he or
  8.   she says so in writing.  Refer to the Aladdin Free Public License (the
  9.   "License") for full details.
  10.   
  11.   Every copy of AFPL Ghostscript must include a copy of the License, normally
  12.   in a plain ASCII text file named PUBLIC.  The License grants you the right
  13.   to copy, modify and redistribute AFPL Ghostscript, but only under certain
  14.   conditions described in the License.  Among other things, the License
  15.   requires that the copyright notice and this notice be preserved on all
  16.   copies.
  17. */
  18.  
  19. /*$Id: math_.h,v 1.2 2000/09/19 19:00:47 lpd Exp $ */
  20. /* Generic substitute for math.h */
  21.  
  22. #ifndef math__INCLUDED
  23. #  define math__INCLUDED
  24.  
  25. /* We must include std.h before any file that includes sys/types.h. */
  26. #include "std.h"
  27.  
  28. #if defined(VMS) && defined(__GNUC__)
  29. /*  DEC VAX/VMS C comes with a math.h file, but GNU VAX/VMS C does not. */
  30. #  include "vmsmath.h"
  31. #else
  32. #  include <math.h>
  33. #endif
  34.  
  35. /* math.h is different for Turbo and Unix.... */
  36. #ifndef M_PI
  37. #  ifdef PI
  38. #    define M_PI PI
  39. #  else
  40. #    define M_PI 3.14159265358979324
  41. #  endif
  42. #endif
  43.  
  44. /* Factors for converting between degrees and radians */
  45. #define degrees_to_radians (M_PI / 180.0)
  46. #define radians_to_degrees (180.0 / M_PI)
  47.  
  48. /*
  49.  * Define the maximum value of a single-precision float.
  50.  * This doesn't seem to be defined in any standard place,
  51.  * and we need an exact value for it.
  52.  */
  53. #undef MAX_FLOAT        /* just in case */
  54. #if defined(vax) || defined(VAX) || defined(__vax) || defined(__VAX)
  55. /* Maximum exponent is +127, 23 bits of fraction. */
  56. #  define MAX_FLOAT\
  57.      ((0x800000 - 1.0) * 0x1000000 * 0x1000000 * 0x10000000 * 0x10000000)
  58. #else
  59. /* IEEE, maximum exponent is +127, 23 bits of fraction + an implied '1'. */
  60. #  define MAX_FLOAT\
  61.      ((0x1000000 - 1.0) * 0x1000000 * 0x1000000 * 0x10000000 * 0x10000000)
  62. #endif
  63.  
  64. /* Define the hypot procedure on those few systems that don't provide it. */
  65. #ifdef _IBMR2
  66. /* The RS/6000 has hypot, but math.h doesn't declare it! */
  67. extern double hypot(double, double);
  68. #else
  69. #  if !defined(__TURBOC__) && !defined(BSD4_2) && !defined(VMS) && !defined(__MWERKS__)
  70. #    define hypot(x,y) sqrt((x)*(x)+(y)*(y))
  71. #  endif
  72. #endif
  73.  
  74. #ifdef OSK
  75. /* OSK has atan2 and ldexp, but math.h doesn't declare them! */
  76. extern double atan2(), ldexp();
  77. #endif
  78.  
  79. /* Intercept calls on sqrt for debugging. */
  80. extern double gs_sqrt(P3(double, const char *, int));
  81. #ifdef DEBUG
  82. #undef sqrt
  83. #define sqrt(x) gs_sqrt(x, __FILE__, __LINE__)
  84. #endif /* DEBUG */
  85.  
  86. #endif /* math__INCLUDED */
  87.